#include <iostream>
#include <vector>
#include <algorithm>
#include "Vector.hpp"
using namespace std;
/*
用hashmap判断数字是否存在，数字没有先导则为一个开头
*/

class Solution
{
public:
    int longestConsecutive(vector<int> &nums)
    {
        if(nums.empty())
            return 0;
        std::sort(nums.begin(), nums.end());
        PrintVector(nums);
        int max_len = 0;
        int cur_len = 1;
        for (size_t i = 0; i < nums.size() - 1; i++)
        {
            if(nums[i] == nums[i + 1])
                continue;
            else if (nums[i] + 1 == nums[i + 1])
                cur_len++;
            else
                cur_len = 1;
            max_len = max(max_len, cur_len);
        }
        max_len = max(max_len, cur_len);
        return max_len;
    }
};

int main()
{
    cout << "Code128" << endl;
    vector<int> nums = {1,2,0,1};
    Solution s;
    cout << s.longestConsecutive(nums) << endl;
    return 0;
}